package com.boot.main.service.impl;

import com.boot.main.entity.CcomSyslog;
import com.boot.main.mapper.CcomSyslogMapper;
import com.boot.main.response.ResponseData;
import com.boot.main.response.ResponseDataUtil;
import com.boot.main.service.ISyslogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SyslogService implements ISyslogService {
    @Resource
    private CcomSyslogMapper syslogMapper;

    @Override
    public ResponseData getSyslog(Integer page, Integer limit, String username){
        List<CcomSyslog> items = syslogMapper.getSyslog((page-1)*limit, limit, username);
        int count = syslogMapper.getTotalCount();
        Map map = new HashMap();
        map.put("datas", items);
        map.put("count", count);
        if(!items.isEmpty()){
            return ResponseDataUtil.success("获取日志列表成功", map);
        }
        return ResponseDataUtil.success("暂无日志信息", map);
    }
}
